package com.py.credit.service.impl;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import com.py.credit.controller.UploadTaiQianController;
import com.py.credit.dao.*;
import com.py.credit.entity.*;
import com.py.credit.service.*;
import com.py.credit.utils.*;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import com.alibaba.fastjson.JSONObject;
import com.py.credit.common.ServiceException;
import com.py.framework.core.common.Page;

@Service
public class DataEntryServiceImpl implements DataEntryService {

	private static final int NUM_1000 = 1000;

	private static final int NUM_1 = 1;

	private static final int NUM_2 = 2;


	protected int socketTimeout = 30000;// 请求超时时间
	protected int connectTimeout = 30000;// 传输超时时间
	//protected String XKPostUrl = "http://59.207.122.239:8080/jiekou/gonggongxinxipingtai_jiekou.php";
	protected String postUrl = "http://59.207.122.239:8080/jiekou/gonggongxinxipingtai_jiekou.php";
	protected String sgs_apiKey = "cc5ddb44b7a92c23cfeab12981a312fd";
	private final Logger log = LoggerFactory.getLogger(UploadTaiQianController.class);
	protected String namespace = "com.test.webservices";//命名空间

	@Autowired
	private UploadXycnDao uploadXycnDao;

	@Autowired
	private UploadService upLoadService;

	@Autowired
	private UploadPublicDao uploadPublicDao;

	@Autowired
	private WriteLogsService writeLogsService;
	
	
	@Autowired
	private DataEntryDao dataEntryDao;

	@Autowired
	private TableDao tableDao;

	@Autowired
	private BatchLogDao batchLogDao;

	@Autowired
	private ColumnService columnService;

	@Autowired
	private DataRelateService dataRelateService;

	@Autowired
	private DataOperateHistoryService dataOperateHistoryService;

	@Override
	public List<Column> getColunmList(int tableId) {
		// TODO 根据用户获取该用户的部门，暂时写死用户id为1
		// int magagerId=1;
		return dataEntryDao.getColunmList(tableId);
	}

	@Override
	public List<Table> getTableList(String code) {
		// 根据用户获取该用户的一级部门，暂时写死用户id为1
		int deptOid = 1;
		return dataEntryDao.getTableList(code, deptOid);
	}

	@Override
	@Transactional
	public void updataData(int tableId, Map<String, Object> map, List<Column> columns, int dataId) {
		Table table = tableDao.selectByPrimaryKey(tableId);
		String tableName = "t_" + table.getResourceId();
		StringBuilder querySql = new StringBuilder();
//		String replacement = "\\'";
		// 拼接查询sql，获取数据的批次ID
		querySql.append("select batch_Id AS batchId from ").append(tableName).append(" where record_id = ")
				.append(dataId).append(" limit 1");
		String batchId = dataEntryDao.selectStringData(querySql.toString());
		StringBuffer sql = new StringBuffer();
		sql.append(" update ");
		sql.append(tableName);
		sql.append(" set ");
		for (int i = 0; i < columns.size(); i++) {
			Column column = columns.get(i);
			sql.append(column.getMetricCode());
			String value = "";
			if (null != map.get(column.getMetricCode())) {
//				value = (String.valueOf(map.get(column.getMetricCode()))).replace("'", replacement);
				value = String.valueOf(map.get(column.getMetricCode()));
			} else {
				value = null;
			}
			if ("number".equals(column.getFieldType())) {
				sql.append(" = ");
				sql.append(StringUtils.isEmpty(value) ? null : value).append(" , ");
			} else if ("timestamp".equals(column.getFieldType())) {
				sql.append(" = ");
				sql.append(StringUtils.isEmpty(value) ? null : "\'" + value + "\'").append(" , ");
			} else {
				sql.append(" = ");
				sql.append(StringUtils.isEmpty(value) ? null : "\'" + value + "\'").append(" , ");
			}
		}
		sql.append("status").append("=").append("\'").append("P").append("\'");
		sql.append(" where ");
		sql.append(" record_id ").append("=");
		sql.append(dataId);
		sql.append(" AND status ").append(" = ").append(" 'E' ");
		// 更新的时候通过查询的creditTime为附加条件，时间改变则更新失败
		int i = dataEntryDao.updataData(sql.toString());
		if (i <= 0) {
			throw new ServiceException("该条数据已变更，请重新查看");
		} else {
			dataEntryDao.updataErrorData(tableId, dataId, "P");
			// 异常数据处理时错误减正确加
			batchLogDao.updateSFcount(batchId);
			// 获取批次信息
			BatchLog batchInfo = batchLogDao.select(batchId);

			map.put("recordId", dataId);
			// 调用数据关联操作
			dataRelateService.relatePerform(tableId, batchInfo.getDatasourceId(), map, batchInfo.getDeptId());
		}
	}

	@Override
	@Transactional
	public void deleteData(int tableId, int dataId) {
		Table table = tableDao.selectByPrimaryKey(tableId);
		String tableName = "t_" + table.getResourceId();
		StringBuilder querySql = new StringBuilder();
		// 拼接查询sql，获取数据的批次ID
		querySql.append("select batch_Id AS batchId from ").append(tableName).append(" where record_id = ")
				.append(dataId).append(" limit 1");
		String batchId = dataEntryDao.selectStringData(querySql.toString());
		StringBuffer sql = new StringBuffer();
		sql.append(" update ");
		sql.append("t_" + table.getResourceId());
		sql.append(" set ");
		sql.append("status").append("=").append("\'").append("D").append("\'");
		sql.append(" where ");
		sql.append(" record_id ").append("=");
		sql.append(dataId);
		sql.append(" AND status ").append(" = ").append(" 'E' ");
		int i = dataEntryDao.updataData(sql.toString());
		if (i <= 0) {
			throw new ServiceException("该条数据已变更，请重新查看");
		} else {
			dataEntryDao.updataErrorData(tableId, dataId, "D");
			// 异常数据处理时错误减正确加
			batchLogDao.updateTFcount(batchId);
		}

	}

	/**
	 * 
	 * @Function 异常数据问题处理
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName getTableListForPage
	 * @param tableId
	 *            表ID
	 * @param startTime
	 *            开始时间
	 * @param endTime
	 *            结束时间
	 * @param page
	 *            分页
	 * @Date 2018年7月17日 下午3:27:36
	 * @Author Min DongXv
	 *
	 */
	@Override
	public List<Map<String, Object>> getTableListForPage(int tableId, String startTime, String endTime, Page page,
			SysUser userInfo,Integer deptId) {
		Table table = tableDao.selectByPrimaryKey(tableId);
		if (null != table && StringUtils.isNotBlank(table.getResourceId())) {
			// 获取所有列
			List<Column> columns = columnService.getListByTableId(table.getTableId());
			String tableName = "t_" + table.getResourceId();
			Date day = new Date();
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			if (startTime.equals("")) {
				// 开始时间默认为一个月前
				Calendar c = Calendar.getInstance();
				c.setTime(day);
				c.add(Calendar.MONTH, -1);
				startTime = df.format(c.getTime());
			}
			if (endTime.equals("")) {
				// 结束时间默认为当天
				endTime = df.format(day);
			}
			// 获取异常的表数据
			List<Map<String, Object>> data = null;
			if(userInfo.getRoleName().equals("系统管理员")) {
				data = dataEntryDao.getTableListForPage(tableName, startTime, endTime, page,
						deptId==null?null:deptId.longValue());
			}else {
				data = dataEntryDao.getTableListForPage(tableName, startTime, endTime, page,
						userInfo.getOfficeId());
			}
			List<Map<String,Object>> newData = new ArrayList<>();
			for (Map<String, Object> m : data) {
				Map<String,Object> map = new LinkedHashMap<String,Object>();
				String jsonValue = "";
				if (null != m) {
					if ("E".equals(m.get("status"))) {
						// 获取异常信息集合
						List<ErrorData> errorDatas = dataEntryDao.getErrorDataListForTableId(tableId,
								Integer.parseInt(String.valueOf(m.get("record_id"))));
						if (!CollectionUtils.isEmpty(errorDatas)) {
							Map<String, String> err = new HashMap<String, String>(errorDatas.size());
							Set<String> msg = new HashSet<String>(3);
							String typeMsgReason = "";
							// 表规则字段规则提示处理
							for (ErrorData e : errorDatas) {
								if (null != e) {
									if ("Z".equals(e.getType())) {
										msg.add("字段规则校验失败");
										err.put(e.getColunmEN(), e.getReason());
									} else if ("B".equals(e.getType())) {
										msg.add("表规则校验失败");
										typeMsgReason = e.getReason();
									} else if ("S".equals(e.getType())) {
										msg.add("数据库规则校验失败");
										typeMsgReason = e.getReason();
										jsonValue = e.getColunmValue();
										// 进行数据填充
										
									}
								}
							}
							map.put("typeMsg", StringUtils.join(msg.toArray(), ",")+err);
							map.put("typeMsgReason", typeMsgReason);
							map.put("errorMess", err);
							map.put("record_id", m.get("record_id"));
							map.put("status", m.get("status"));
							map.put("tybm", m.get("tybm"));
							map.put("md5", m.get("md5"));
							for(Column column :columns) {								
								if("".equals(m.get(column.getMetricCode())) || null == (m.get(column.getMetricCode()))) {
									map.put(column.getMetricCode(), "");
								}else {
									map.put(column.getMetricCode(), m.get(column.getMetricCode()));
								}								
							}
//							for (Entry<String, Object> entry : m.entrySet()) {
//								if("".equals(entry.getValue()) || null == (entry.getValue()))
//								map.put(entry.getKey(), "");
//								else
//								map.put(entry.getKey(), entry.getValue());
//							}
							if (StringUtils.isNotBlank(jsonValue) && !CollectionUtils.isEmpty(columns)) {
								JSONObject jb = JSONObject.parseObject(jsonValue);
								for (Column c : columns) {
									String code = c.getMetricCode();
									map.put(code, jb.getString(code));
								}
							}
						}
					}
				}
				newData.add(map);
			}
			return newData;
		} else {
			return new ArrayList<Map<String, Object>>();
		}
	}

	/**
	 * 
	 * @Function 成功数据入库
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName addSuccessData
	 * @param listDataMap
	 * @param table
	 * @param batchLog
	 * @param columns
	 * @Date 2018年7月10日 上午10:24:41
	 * @Author Min DongXv
	 *
	 */
	@Override
	public void addSuccessData(List<Map<String, Object>> listDataMap, Table table, BatchLog batchLog,
			List<Column> columns) {
		// 根据关联规则查询唯一标识符(根据表的id查询库的code,根据code选用那个库的匹配规则)
		StringBuilder sql = new StringBuilder(200);
		sql.append(" insert into  ");
		sql.append("t_" + table.getResourceId());
		sql.append(" ( ");
		sql.append("tybm, ");
		for (int i = 0; i < columns.size(); i++) {
			sql.append(columns.get(i).getMetricCode());
			sql.append(" , ");
		}
		if (table.getResourceId().equals("dc_focus_company_new")) {
			sql.append("time,");
			sql.append("userId,");
		}
		sql.append("status,");
		sql.append("md5,");
		sql.append("batch_id");
		sql.append(" ) ");
		sql.append(" VALUES  ");
		String headSql = sql.toString();
		if (!CollectionUtils.isEmpty(listDataMap)) {
			// 分批次批量插入
			if (listDataMap.size() > NUM_1000) {
				int num = listDataMap.size() / NUM_1000;
				int restNum = listDataMap.size() % NUM_1000;
				for (int i = 0; i < num; i++) {
					List<Map<String, Object>> part = listDataMap.subList(0 + i * NUM_1000, 999 + i * NUM_1000);
					// 添加正确数据
					insertData(part, batchLog, columns, headSql,"t_" + table.getResourceId());
				}
				if (restNum > 0) {
					List<Map<String, Object>> rest = listDataMap.subList(num * NUM_1000, listDataMap.size());
					// 添加正确数据
					insertData(rest, batchLog, columns, headSql,"t_" + table.getResourceId());
				}
			} else {
				// 添加正确数据
				insertData(listDataMap, batchLog, columns, headSql,"t_" + table.getResourceId());
			}
		}
	}

	/**
	 * 
	 *
	 * @Function 创建临时表
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName createTempTable
	 * @param tableName
	 *            表名
	 * @param columns
	 *            列字段
	 * @Date 2018年8月21日 上午10:09:02
	 * @Author Min DongXv
	 *
	 */
	@Override
	public void createTempTable(String tableName, List<Column> columns) {
		String sql = SQLBuilder.createTempTableSql(tableName, columns);
		dataEntryDao.createTempTable(sql);
	}

	/**
	 * 
	 *
	 * @Function 更新临时表中重复数据的状态为S
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName updateStatus
	 * @param tableRes
	 *            源表
	 * @param tableDes
	 *            目标表
	 * @Date 2018年8月21日 上午10:09:31
	 * @Author Min DongXv
	 *
	 */
	@Override
	public void updateStatus(String tableRes, String tableDes) {
		dataEntryDao.updateTempTableData(tableRes, tableDes);
	}

	/**
	 * 
	 *
	 * @Function 删除临时表
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName dropTempTable
	 * @param tableName
	 *            表名
	 * @Date 2018年8月21日 上午10:12:21
	 * @Author Min DongXv
	 *
	 */
	@Override
	public void dropTempTable(String tableName) {
		dataEntryDao.dropTempTable(tableName);
	}

	/**
	 * 
	 * @Function 查询临时表数据
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName countDataNum
	 * @param tableName
	 *            表名
	 * @return
	 * @Date 2018年8月21日 上午10:50:58
	 * @Author Min DongXv
	 *
	 */
	@Override
	public int countDataNum(String tableName, String status) {
		return dataEntryDao.countDataNum(tableName, status);
	}

	/**
	 *
	 * @Function 数据拷贝
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName copyData
	 * @param tableRes
	 *            源表
	 * @param tableDes
	 *            目标表
	 * @param columns
	 *            字段列
	 * @Date 2018年8月21日 上午11:13:32
	 * @Author Min DongXv
	 *
	 */
	@Override
	public void copyData(String tableRes, String tableDes, List<Column> columns) {
		String col = "";
		for (Column c : columns) {
			col = col + c.getMetricCode() + ", ";
		}
		StringBuilder sb = new StringBuilder(200);
		sb.append("INSERT INTO ").append(tableDes).append(" (status,tybm,md5,batch_Id,").append(col).append("address) ")
				.append(" SELECT ").append(" status,tybm,md5,batch_Id,").append(col).append("address ").append(" FROM ")
				.append(tableRes).append(" WHERE status = 'S' ");
		dataEntryDao.copyData(sb.toString());
	}

	/**
	 *
	 * @Function 清空内存表数据
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName clearTable
	 * @param tableName
	 *            表名
	 * @Date 2018年8月21日 下午1:43:31
	 * @Author Min DongXv
	 *
	 */
	@Override
	public void clearTable(String tableName) {
		dataEntryDao.clearTable(tableName);
	}

	/**
	 * 
	 * @Function 添加数据到内存表
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName addDataToTemp
	 * @param listDataMap
	 *            数据列表
	 * @param table
	 *            表信息
	 * @param batchLog
	 *            批次信息
	 * @param columns
	 *            字段列信息
	 * @param tableName
	 *            表名
	 * @Date 2018年8月21日 上午10:14:49
	 * @Author Min DongXv
	 *
	 */
	@Override
	public void addDataToTemp(List<Map<String, Object>> listDataMap, Table table, BatchLog batchLog,
			List<Column> columns, String tableName) {
		// 根据关联规则查询唯一标识符(根据表的id查询库的code,根据code选用那个库的匹配规则)
		StringBuilder sql = new StringBuilder(200);
		sql.append(" insert into  ");
		sql.append(tableName);
		sql.append(" ( ");
		sql.append("tybm, ");
		for (int i = 0; i < columns.size(); i++) {
			sql.append(columns.get(i).getMetricCode());
			sql.append(" , ");
		}
		if (table.getResourceId().equals("dc_focus_company_new")) {
			sql.append("time,");
			sql.append("userId,");
		}
		sql.append("status,");
		sql.append("md5,");
		sql.append("batch_id");
		sql.append(" ) ");
		sql.append(" VALUES  ");
		String headSql = sql.toString();
		
		if (!CollectionUtils.isEmpty(listDataMap)) {
			// 分批次批量插入
			if (listDataMap.size() > NUM_1000) {
				int num = listDataMap.size() / NUM_1000;
				int restNum = listDataMap.size() % NUM_1000;
				for (int i = 0; i < num; i++) {
					List<Map<String, Object>> part = listDataMap.subList(0 + i * NUM_1000, NUM_1000 + i * NUM_1000);
					// 添加正确数据
					insertData(part, batchLog, columns, headSql,tableName);
				}
				if (restNum > 0) {
					List<Map<String, Object>> rest = listDataMap.subList(num * NUM_1000, listDataMap.size());
					// 添加正确数据
					insertData(rest, batchLog, columns, headSql,tableName);
				}
			} else {
				// 添加正确数据
				insertData(listDataMap, batchLog, columns, headSql,tableName);
			}
			
		}
	}

	/**
	 * 
	 *
	 * @Function 实体表数据更新操作
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName editData
	 * @param tableId
	 *            表ID
	 * @param map
	 *            数据MAP
	 * @param columns
	 *            列信息
	 * @param dataId
	 *            数据ID
	 * @Date 2018年9月28日 下午2:32:32
	 * @Author Min DongXv
	 *
	 */
	@Override
	@Transactional
	public void editData(int tableId, Map<String, Object> map, List<Column> columns, int dataId, SysUser userInfo) {
		// 获取表信息
		Table table = tableDao.selectByPrimaryKey(tableId);
		// 表名
		String tableName = "t_" + table.getResourceId();
		StringBuilder querySql = new StringBuilder();
		String batchId = null;
		String md5 = null;
		String status = null;
		// 拼接查询sql，获取数据
		querySql.append("select * from ").append(tableName).append(" where record_id = ").append(dataId)
				.append(" limit 1");
		// 获取单条数据批次，MD5，装态信息
		List<Map<String, Object>> dataRecord = dataEntryDao.selectListData(querySql.toString());
		Map<String, Object> dataInfo = null;
		if (!CollectionUtils.isEmpty(dataRecord)) {
			dataInfo = dataRecord.get(0);
			if (!CollectionUtils.isEmpty(dataInfo)) {
				batchId = String.valueOf(dataInfo.get("batch_Id"));
				md5 = String.valueOf(dataInfo.get("md5"));
				status = String.valueOf(dataInfo.get("status"));
			}
		}
		// MD5重新计算
		StringBuilder md5Data = new StringBuilder();
		StringBuilder sql = new StringBuilder();
		sql.append(" update ");
		sql.append(tableName);
		sql.append(" set ");
		for (Column column : columns) {
			sql.append(column.getMetricCode());
			String value = "";
			if (null != map.get(column.getMetricCode())) {
				value = String.valueOf(map.get(column.getMetricCode()));
			} else {
				value = null;
			}
			if ("number".equals(column.getFieldType())) {
				sql.append(" = ");
				sql.append(StringUtils.isEmpty(value) ? null : value).append(" , ");
			} else if ("timestamp".equals(column.getFieldType())) {
				sql.append(" = ");
				sql.append(StringUtils.isEmpty(value) ? null : "\'" + value + "\'").append(" , ");
			} else {
				sql.append(" = ");
				sql.append(StringUtils.isEmpty(value) ? null : "\'" + value + "\'").append(" , ");
			}
			md5Data.append(column.getMetricCode()).append("|");
			md5Data.append(StringUtils.isBlank(value) ? "" : value);
		}
		// 进行MD5计算
		String nowMd5 = MD5Util.getInstance().md5s(md5Data.toString().getBytes());
		// MD5不一致，进行数据修改
		if (!nowMd5.equals(md5)) {
			String nowStatus = "P";
			// 进行装态变更，异常、重复、状态变为P(已修复)，其他状态维持不变
			if (!"E".equals(status) && !"R".equals(status)) {
				nowStatus = status;
			}
			sql.append(" status ").append("=").append("\'").append(nowStatus).append("\'").append(" , ");
			sql.append(" md5 ").append("=").append("\'").append(nowMd5).append("\'");
			sql.append(" where ");
			sql.append(" record_id ").append("=").append(dataId);
			sql.append(" AND status ").append(" = '").append(status).append("'");
			sql.append(" AND md5 ").append(" = '").append(md5).append("'");
			// 更新的时候通过查询的附加条件，改变则更新失败
			int i = dataEntryDao.updataData(sql.toString());
			if (i <= 0) {
				throw new ServiceException("该条数据已变更，请重新查看");
			} else {
				if ("E".equals(status)) {
					dataEntryDao.updataErrorData(tableId, dataId, "P");
					// 异常数据处理时错误减正确加
					batchLogDao.updateSFcount(batchId);
				} else if ("R".equals(status)) {
					// 错误数据已不入库，但保留这个判断操作
					dataEntryDao.updataErrorData(tableId, dataId, "P");
					// 重复数据修改时进行重复减正确加
					batchLogDao.updateSRcount(batchId);
				}
				// 只要进行了数据更新操作都进行重新关联
				// 获取批次信息
				BatchLog batchInfo = batchLogDao.select(batchId);
				map.put("recordId", dataId);
				DataOperateHistoryEntity entity = new DataOperateHistoryEntity();
				entity.setDeptId(userInfo.getOfficeId());
				entity.setManagerId(userInfo.getId());
				entity.setNowStatus(nowStatus);
				entity.setOperateStatus(NUM_1);
				entity.setOriginData(JSONObject.toJSONString(dataInfo));
				entity.setOriginStatus(status);
				entity.setRecordId(dataId);
				entity.setTableId(tableId);
				dataOperateHistoryService.addDataOperateHistory(entity);
				// 调用数据关联操作
				dataRelateService.relatePerform(tableId, batchInfo.getDatasourceId(), map, batchInfo.getDeptId());
				//调用市平台推送接口
				int type =99;
				String methodName="";
				String methodId="";
				if("t_1000000010001_3ioj4gezqu".toUpperCase().equals(tableName.toUpperCase())){//法人许可0
					type =0;
					methodName="importPermissionXml";
					methodId="10";
				}else if("t_1000000010002_xsni4zszp0".toUpperCase().equals(tableName.toUpperCase())){//法人处罚 2
					type =2;
					methodName="importPenalyXml";
					methodId="11";
				}else if("t_1000000010252_akk9bUnaL3".toUpperCase().equals(tableName.toUpperCase())){//监督检查 4
					type =4;
					methodName="importJdjcXml";
					methodId="12";
				}else if("t_1000000010019_bgWiiN00cb".toUpperCase().equals(tableName.toUpperCase())){//行政强制 6
					type =6;
					methodName="importXzqzXml";
					methodId="13";
				}else if("t_1000000010045_6HelrLv0OJ".toUpperCase().equals(tableName.toUpperCase())){//行政征收 8
					type =8;
					methodName="importXzzsXml";
					methodId="14";
				}else if("t_1000000010081_B1jxBXNyHJ".toUpperCase().equals(tableName.toUpperCase())){//行政给付 10
					type =10;
					methodName="importXzjfXml";
					methodId="15";
				}else if("t_1000000010082_LuLlDPXj9d".toUpperCase().equals(tableName.toUpperCase())){// 行政奖励12
					type =12;
					methodName="importXzjlXml";
					methodId="16";
				}else if("t_1000000010078_72Blr6pCCj".toUpperCase().equals(tableName.toUpperCase())){//行政裁决 14
					type =14;
					methodName="importXzcjXml";
					methodId="17";
				}else if("t_1000000010079_fel4Oc0gfQ".toUpperCase().equals(tableName.toUpperCase())){//行政确认 16
					type =16;
					methodName="importXzqrXml";
					methodId="18";
				}else if("t_1000000010083_bisEXzGGeF".toUpperCase().equals(tableName.toUpperCase())){// 其他行政管理 18
					type =18;
					methodName="importQtxzzfxxXml";
					methodId="19";
				}else if("t_1000000010398_agbpz1ybsl".toUpperCase().equals(tableName.toUpperCase())){ //行用承诺  20
					type =20;
					methodName="importXycnXml";
					methodId="21";
				}else if("t_1000000010410_dwaw88YojG".toUpperCase().equals(tableName.toUpperCase())){//任务抽查 22
					type =22;
					methodName="importCcRwXml";
					methodId="23";
				}else if("t_1000000010409_sUlP9D0Apy".toUpperCase().equals(tableName.toUpperCase())){//抽查结果 24
					type =24;
					methodName="importCcJgXml";
					methodId="24";
				}
                try {
                    Object data = execute(type,namespace, postUrl,  methodName,methodId, sgs_apiKey,dataId);
                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e);
                }
			}
		}
	}

	/**
	 * 
	 *
	 * @Function 数据删除
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName delData
	 * @param tableId
	 *            表ID
	 * @param dataId
	 *            数据记录ID
	 * @Date 2018年9月28日 下午3:24:33
	 * @Author Min DongXv
	 *
	 */
	@Override
	@Transactional
	public void delData(int tableId, int dataId, SysUser userInfo) {
		// 获取表信息
		Table table = tableDao.selectByPrimaryKey(tableId);
		// 表名
		String tableName = "t_" + table.getResourceId();
		StringBuilder querySql = new StringBuilder();

		String batchId = null;
		String status = null;
		// 拼接查询sql，获取数据
		querySql.append("select * from ").append(tableName).append(" where record_id = ").append(dataId)
				.append(" limit 1");
		// 获取单条数据批次，MD5，装态信息
		List<Map<String, Object>> dataRecord = dataEntryDao.selectListData(querySql.toString());
		Map<String, Object> dataInfo = null;
		if (!CollectionUtils.isEmpty(dataRecord)) {
			dataInfo = dataRecord.get(0);
			if (!CollectionUtils.isEmpty(dataInfo)) {
				batchId = String.valueOf(dataInfo.get("batch_Id"));
				status = String.valueOf(dataInfo.get("status"));
			}
		}
		StringBuilder sql = new StringBuilder();
		sql.append(" update ");
		sql.append("t_" + table.getResourceId());
		sql.append(" set ");
		sql.append("status").append("=").append("\'").append("D").append("\'").append(" , ");
		sql.append("md5").append("=").append(" null ");
		sql.append(" where ");
		sql.append(" record_id ").append("=").append(dataId);
		sql.append(" AND status ").append(" = '").append(status).append("'");
		int i = dataEntryDao.updataData(sql.toString());
		if (i <= 0) {
			throw new ServiceException("该条数据已变更，请重新查看");
		} else {
			if ("E".equals(status)) {
				dataEntryDao.updataErrorData(tableId, dataId, "D");
				// 删除错误数据时总数减错误数减
				batchLogDao.updateTFcount(batchId);
			} else if ("R".equals(status)) {
				// 错误数据已不入库，但保留这个判断操作
				dataEntryDao.updataErrorData(tableId, dataId, "D");
				// 删除重复数据时总数减重复数减
				batchLogDao.updateTRcount(batchId);
			} else {
				// 删除正确数据时总数减正确数减
				batchLogDao.updateTScount(batchId);
			}
			DataOperateHistoryEntity entity = new DataOperateHistoryEntity();
			entity.setDeptId(userInfo.getOfficeId());
			entity.setManagerId(userInfo.getId());
			entity.setNowStatus("D");
			entity.setOperateStatus(NUM_2);
			entity.setOriginData(JSONObject.toJSONString(dataInfo));
			entity.setOriginStatus(status);
			entity.setRecordId(dataId);
			entity.setTableId(tableId);
			dataOperateHistoryService.addDataOperateHistory(entity);
		}
	}

	/**
	 * 
	 * @Function 批量数据插入
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName insertData
	 * @param listDataMap
	 *            数据集
	 * @param batchLog
	 *            批次信息
	 * @param columns
	 *            字段信息
	 * @param headSql
	 *            头部sql
	 * @return
	 * @Author Min DongXv
	 *
	 */
	private void insertData(List<Map<String, Object>> listDataMap, BatchLog batchLog, List<Column> columns,
			String headSql,String tablename) {
		List<String> datas = new ArrayList<>(listDataMap.size());
		for (Map<String, Object> dataMap : listDataMap) {
			if(dataMap.containsKey("taskId")) {
				dataEntryDao.deleteErrData(dataMap.get("taskId").toString(),tablename);
			}
			StringBuilder dataSql = new StringBuilder(500);
			buildSql(dataSql, "S", " ", batchLog.getId(), columns, dataMap);
			datas.add(dataSql.toString());
		}
		if (!CollectionUtils.isEmpty(datas)) {
			// 添加正确数据
			DynamicSqlEntity entity = new DynamicSqlEntity(headSql + StringUtils.join(datas, ","));
			
			dataEntryDao.addData(entity);
		}
	}

	/**
	 * 
	 * @Function sql生成
	 * @FileName DataEntryServiceImpl.java
	 * @MethodName buildSql
	 * @param sql
	 *            待增补的sql
	 * @param status
	 *            状态 S:成功 W:待关联
	 * @param tybm
	 * @param batchLogId
	 *            批次ID
	 * @param columns
	 *            列信息列表
	 * @param next
	 *            本条数据
	 * @return
	 * @Date 2018年7月2日 上午10:03:54
	 * @Author Min DongXv
	 *
	 */
	private void buildSql(StringBuilder sql, String status, String tybm, String batchLogId, List<Column> columns,
			Map<String, Object> next) {
		sql.append(" ( ");
		sql.append("\'").append(tybm).append("\'").append(", ");
		for (Column column : columns) {
			String value = "";
			if (null != next.get(column.getMetricCode())) {
				
				if(column.getMetricCode().contains("WSH")) {
					value = String.valueOf(next.get(column.getMetricCode())).replaceAll("\\[", "〔").replaceAll("\\]", "〕").
		        			replaceAll("【", "〔").replaceAll("】", "〕").
		        			replaceAll("﹝", "〔").replaceAll("﹞", "〕").
		        			replaceAll("［", "〔").replaceAll("］", "〕").
		        			replaceAll("\\{", "〔").replaceAll("\\}", "〕");	
				}else {
					value = String.valueOf(next.get(column.getMetricCode())).replace("\'", "").replace("；", ";");
				}
				
			} else {
				value = null;
			}
			if ("number".equals(column.getFieldType())) {
				sql.append(StringUtils.isEmpty(value) ? null : value).append(" , ");
			} else if ("timestamp".equals(column.getFieldType())) {
				sql.append(StringUtils.isEmpty(value) ? null : "\'" + value + "\'").append(" , ");
			} else {
				sql.append(StringUtils.isEmpty(value) ? null : "\'" + value + "\'").append(" , ");
			}
		}
		sql.append("\'").append(status).append("\'").append(", ");
		sql.append("\'").append(String.valueOf(next.get("MD5"))).append("\'").append(", ");
		sql.append("\'").append(batchLogId).append("\'");
		sql.append(" )");
	}

	//推送市平台

	/**
	 *
	 * @param type 0 法人许可 1 自然人许可 2 法人处罚 3 自然人处罚  4 法人监督检查 5 自然人监督检查6 法人行政强制
	 *             7 自然人行政强制8 法人行政征收 9 自然人行政征收10 法人行政给付 11 自然人行政给付12 法人行政奖励
	 *             13 自然人行政奖励14 法人行政裁决 15 自然人行政裁决16 法人行政确认 17 自然人行政确认
	 *             18 法人其他行政管理 19 自然人其他行政管理20 法人信用承诺 21 自然人信用承诺22 法人抽查任务
	 *             23 自然人抽查任务24 法人抽查结果 25 自然人抽查结果
	 * @param postUrl
	 * @param method
	 * @return
	 * @throws UnsupportedEncodingException
	 */

	public String execute(int type,String namespace, String postUrl, String method,String methodid,  String apiKey,int dataId) throws UnsupportedEncodingException {
		try {
			Date reqDate = new Date();
			String tableName="";
			if(type==0){//0 法人许可
				tableName="t_1000000010001_3ioj4gezqu";
				List<SubmitXzxkBean> xzxkList = upLoadService.getXzXkList();
				List<List<SubmitXzxkBean>> parList = ListUtils.partition(xzxkList, 1);

				for (int i = 0; i < parList.size(); i++) {
					List<SubmitXzxkBean> spXkList = parList.get(i);
					if(spXkList.get(i).getId().equals(String.valueOf(dataId))) {
						SubmitReqData req = new SubmitReqData();
						req.setXzxk(spXkList);

						// 上报数据转换成xml
						String xzxkXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("上报数据转换成xml" + xzxkXmlValue);
						log.debug("行政许可转XML内容：{}", xzxkXmlValue);
						//tid  10
						String respXzxkValue = doPostSoap(postUrl, xzxkXmlValue, apiKey, method, methodid, "xxid_001");
//                    String respXzxkValue = "{\"status\":\"00\",\"zongnum\":1,\"chenggongnum\":0,\"shibainum\":1,\"exlfileid\":null,\"subtext\":[{\"hangid\":1,\"zhuangtai\":\"2\",\"cuowustr\":\"\\u7701\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u4e0a\\u62a5\\u6570\\u636e\\u4e0e\\u6570\\u636e\\u5e93\\u4e2d\\u6570\\u636e\\u91cd\\u590d;\"}]}";
						Date resDate = new Date();
						log.info("返回行政许可上报结果信息：{}", respXzxkValue);
						System.out.println("返回行政许可上报结果信息：{}" + respXzxkValue);
//                    SubmitXzxkRespData xzxkResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzxkValue);
						//保存返回数据
						List<String> recordIds = spXkList.stream().map(SubmitXzxkBean -> SubmitXzxkBean.getId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzxkResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzxkValue, recordIds, type, reqDate, resDate);
						//return respXzxkValue;
					}
				}

			}else if(type==1){//1 自然人许可
				tableName="t_1000010010003_vVwjDLoDWy";
				List<SubmitXzxkBean> xzxkList = upLoadService.getZrrXzXkList();
				List<List<SubmitXzxkBean>> parList = ListUtils.partition(xzxkList, 1);

				for (int i = 0; i < parList.size(); i++) {
					List<SubmitXzxkBean> spXkList = parList.get(i);
					if(spXkList.get(i).getId().equals(String.valueOf(dataId))) {
						SubmitReqData req = new SubmitReqData();
						req.setXzxk(spXkList);
						// 上报数据转换成xml
						String xzxkXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("上报自然人许可数据转换成xml" + xzxkXmlValue);
						log.debug("自然人行政许可转XML内容：{}", xzxkXmlValue);
						String respXzxkValue = doPostSoap(postUrl, xzxkXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回自然人行政许可上报结果信息：{}", respXzxkValue);
						System.out.println("返回自然人行政许可上报结果信息：{}" + respXzxkValue);
//                    SubmitXzxkRespData xzxkResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzxkValue);
						//保存返回数据
						List<String> recordIds = spXkList.stream().map(SubmitXzxkBean -> SubmitXzxkBean.getId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzxkResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzxkValue, recordIds, type, reqDate, resDate);
						//return respXzxkValue;
					}

				}

			}else if(type==2){//2 法人处罚

				tableName="t_1000000010002_xsni4zszp0";
				List<SubmitXzcfBean> xzCfList = upLoadService.getFrXzCfList();
				List<List<SubmitXzcfBean>> parList = ListUtils.partition(xzCfList, 1);

				for (int i = 0; i < parList.size(); i++) {
					List<SubmitXzcfBean> spCfList = parList.get(i);
					if(spCfList.get(i).getId().equals(String.valueOf(dataId))) {
						SubmitReqData req = new SubmitReqData();
						req.setXzcf(spCfList);
						// 上报数据转换成xml
						String xzCfXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("上报行政处罚数据转换成xml" + xzCfXmlValue);
						log.debug("行政处罚转XML内容：{}", xzCfXmlValue);
						String respXzxkValue = doPostSoap(postUrl, xzCfXmlValue, apiKey, method, methodid, "xxid_001");
//                    String respXzxkValue = "{\"status\":\"00\",\"zongnum\":14,\"chenggongnum\":1,\"shibainum\":13,\"exlfileid\":\"\",\"subtext\":[{\"hangid\":1,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":2,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":3,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":4,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":5,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":6,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":7,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":8,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":9,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":10,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":11,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":12,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":13,\"zhuangtai\":\"3\",\"cuowustr\":\"\\u5e02\\u63a5\\u53e3\\u53cd\\u9988\\uff1a\\u8fdf\\u62a5\"},{\"hangid\":14,\"zhuangtai\":\"1\",\"cuowustr\":\"\"}]}";
						Date resDate = new Date();
						log.info("返回行政处罚上报结果信息：{}", respXzxkValue);
						System.out.println("返回行政处罚上报结果信息：{}" + respXzxkValue);
//                    SubmitXzxkRespData xzCfResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzxkValue);
						//保存返回数据
						List<String> recordIds = spCfList.stream().map(SubmitXzcfBean -> SubmitXzcfBean.getId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzCfResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzxkValue, recordIds, type, reqDate, resDate);
					}
				}

			}else if(type==3){//3 自然人处罚
				tableName="t_1000010010004_kfpulzpf7d";
				List<SubmitXzcfBean> xzCfList = upLoadService.getZrrXzCfList();
				List<List<SubmitXzcfBean>> parList = ListUtils.partition(xzCfList, 1);

				for (int i = 0; i < parList.size(); i++) {
					List<SubmitXzcfBean> spCfList = parList.get(i);
					if(spCfList.get(i).getId().equals(String.valueOf(dataId))) {
						SubmitReqData req = new SubmitReqData();
						req.setXzcf(spCfList);
						// 上报数据转换成xml
						String xzCfXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("上报行政处罚数据转换成xml" + xzCfXmlValue);
						log.debug("行政处罚转XML内容：{}", xzCfXmlValue);
						String respXzxkValue = doPostSoap(postUrl, xzCfXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回行政处罚上报结果信息：{}", respXzxkValue);
						System.out.println("返回行政处罚上报结果信息：{}" + respXzxkValue);
//                    SubmitXzxkRespData xzCfResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzxkValue);
						//保存返回数据
						List<String> recordIds = spCfList.stream().map(SubmitXzcfBean -> SubmitXzcfBean.getId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzCfResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzxkValue, recordIds, type, reqDate, resDate);
					}
				}
			}else if(type==4) {//4 法人监督检查
				tableName="t_1000000010252_akk9bUnaL3";
				List<SupervisoryReview> list = uploadPublicDao.getSupervisoryReviewByFr(tableName);
				List<List<SupervisoryReview>> parList = ListUtils.partition(list, 1);

				for (int i = 0; i < parList.size(); i++) {
					List<SupervisoryReview> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzjc(spList);
						String xzjcXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("监督检查转XML内容：{}" + xzjcXmlValue);
						log.debug("监督检查转XML内容：{}", xzjcXmlValue);
						String respXzxkValue = doPostSoap(postUrl, xzjcXmlValue, apiKey, method, methodid, "xxid_001");
						log.info("返回监督检查上报结果信息：{}", respXzxkValue);
//                    SubmitXzxkRespData xzjcResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzxkValue);
						//保存返回数据
						Date resDate = new Date();
						List<String> recordIds = spList.stream().map(SupervisoryReview -> SupervisoryReview.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzjcResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzxkValue, recordIds, type, reqDate, resDate);
						//return respXzxkValue;
					}
				}
			}else if(type==5) {//5 自然人监督检查
				tableName="t_1000010010430_E0pP6YlewE";
				List<SupervisoryReview> list = uploadPublicDao.getSupervisoryReviewByZrr(tableName);
				List<List<SupervisoryReview>> parList = ListUtils.partition(list, 1);

				for (int i = 0; i < parList.size(); i++) {
					List<SupervisoryReview> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzjc(spList);
						String xzjcXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("监督检查转XML内容：{}" + xzjcXmlValue);
						log.debug("监督检查转XML内容：{}", xzjcXmlValue);
						String respXzxkValue = doPostSoap(postUrl, xzjcXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回监督检查上报结果信息：{}", respXzxkValue);
//                    SubmitXzxkRespData xzjcResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzxkValue);
						//保存返回数据

						List<String> recordIds = spList.stream().map(SupervisoryReview -> SupervisoryReview.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzjcResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzxkValue, recordIds, type, reqDate, resDate);
						//return respXzxkValue;
					}
				}
			}else if(type==6) {//6 法人行政强制
				tableName="t_1000000010019_bgWiiN00cb";
				List<XzqzEntity> list = uploadPublicDao.getXzqzByFr(tableName);
				List<List<XzqzEntity>> parList = ListUtils.partition(list, 1);

				for (int i = 0; i < parList.size(); i++) {
					List<XzqzEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzqz(spList);
						String xzqzXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政强制转XML内容：{}" + xzqzXmlValue);
						log.debug("行政强制转XML内容：{}", xzqzXmlValue);
						String respXzqzValue = doPostSoap(postUrl, xzqzXmlValue, apiKey, method, methodid, "xxid_001");
						log.info("返回行政强制上报结果信息：{}", xzqzXmlValue);
//                    SubmitXzxkRespData xzqzResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzqzValue);
						//保存返回数据
						Date resDate = new Date();
						List<String> recordIds = spList.stream().map(XzqzEntity -> XzqzEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzqzResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzqzValue, recordIds, type, reqDate, resDate);
						//return respXzqzValue;
					}
				}
			}else if(type==7) {//7 自然人行政强制
				tableName="t_1000010010085_nbWY1hOWBB";
				List<XzqzEntity> list = uploadPublicDao.getXzqzByZrr(tableName);
				List<List<XzqzEntity>> parList = ListUtils.partition(list, 1);

				for (int i = 0; i < parList.size(); i++) {
					List<XzqzEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzqz(spList);
						String xzqzXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政强制转XML内容：{}" + xzqzXmlValue);
						log.debug("行政强制转XML内容：{}", xzqzXmlValue);
						String respXzqzValue = doPostSoap(postUrl, xzqzXmlValue, apiKey, method, methodid, "xxid_001");
						log.info("返回行政强制上报结果信息：{}", xzqzXmlValue);
//                    SubmitXzxkRespData xzqzResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzqzValue);
						//保存返回数据
						Date resDate = new Date();
						List<String> recordIds = spList.stream().map(XzqzEntity -> XzqzEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzqzResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzqzValue, recordIds, type, reqDate, resDate);
						//return respXzqzValue;
					}
				}
			}else if(type==8) {//8 法人行政征收
				tableName="t_1000000010045_6HelrLv0OJ";
				List<XzzsEntity> list = uploadPublicDao.getXzzsFr(tableName);
				List<List<XzzsEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzzsEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzzs(spList);
						String xzzsXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政征收转XML内容：{}" + xzzsXmlValue);
						log.debug("行政征收转XML内容：{}", xzzsXmlValue);
						String respXzzsValue = doPostSoap(postUrl, xzzsXmlValue, apiKey, method, methodid, "xxid_001");
						log.info("返回行政征收上报结果信息：{}", respXzzsValue);
//                    SubmitXzxkRespData xzzsResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzzsValue);
						//保存返回数据
						Date resDate = new Date();
						List<String> recordIds = spList.stream().map(XzzsEntity -> XzzsEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzzsResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzzsValue, recordIds, type, reqDate, resDate);
						//return respXzzsValue;
					}
				}
			}else if(type==9) {//9 自然人行政征收
				tableName="t_1000010010089_NKoHe65W3V";
				List<XzzsEntity> list = uploadPublicDao.getXzzsByZrr(tableName);
				List<List<XzzsEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzzsEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzzs(spList);
						String xzzsXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政征收转XML内容：{}" + xzzsXmlValue);
						log.debug("行政征收转XML内容：{}", xzzsXmlValue);
						String respXzzsValue = doPostSoap(postUrl, xzzsXmlValue, apiKey, method, methodid, "xxid_001");
						log.info("返回行政征收上报结果信息：{}", respXzzsValue);
//                    SubmitXzxkRespData xzzsResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzzsValue);
						//保存返回数据
						Date resDate = new Date();
						List<String> recordIds = spList.stream().map(XzzsEntity -> XzzsEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzzsResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzzsValue, recordIds, type, reqDate, resDate);
						//return respXzzsValue;
					}

				}
			}else if(type==10) {//10 法人行政给付
				tableName="t_1000000010081_B1jxBXNyHJ";
				List<XzjfEntity> list = uploadPublicDao.getXzjfByFr(tableName);
				List<List<XzjfEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzjfEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzjf(spList);
						String xzjfXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政给付转XML内容：{}" + xzjfXmlValue);
						log.debug("行政给付转XML内容：{}", xzjfXmlValue);
						String respXzjfValue = doPostSoap(postUrl, xzjfXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回给付征收上报结果信息：{}", respXzjfValue);
//                    SubmitXzxkRespData xzjfResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzjfValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(XzjfEntity -> XzjfEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzjfResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzjfValue, recordIds, type, reqDate, resDate);
						//return respXzjfValue;
					}
				}
			}else if(type==11) {//11 自然人行政给付
				tableName="t_1000010010092_FnFxdTFOv9";
				List<XzjfEntity> list = uploadPublicDao.getXzjfByZrr(tableName);
				List<List<XzjfEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzjfEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzjf(spList);
						String xzjfXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政给付转XML内容：{}" + xzjfXmlValue);
						log.debug("行政给付转XML内容：{}", xzjfXmlValue);
						String respXzjfValue = doPostSoap(postUrl, xzjfXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回给付征收上报结果信息：{}", respXzjfValue);
//                    SubmitXzxkRespData xzjfResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzjfValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(XzjfEntity -> XzjfEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzjfResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzjfValue, recordIds, type, reqDate, resDate);
						//return respXzjfValue;
					}

				}
			}else if(type==12) {//12 法人行政奖励
				tableName="t_1000000010082_LuLlDPXj9d";
				List<XzjlEntity> list = uploadPublicDao.getXzjlByFr(tableName);
				List<List<XzjlEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzjlEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzjl(spList);
						String xzjlXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政激励转XML内容：{}" + xzjlXmlValue);
						log.debug("行政激励转XML内容：{}", xzjlXmlValue);
						String respXzjlValue = doPostSoap(postUrl, xzjlXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回行政激励上报结果信息：{}", respXzjlValue);
//                    SubmitXzxkRespData xzjlResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzjlValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(XzjlEntity -> XzjlEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzjlResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzjlValue, recordIds, type, reqDate, resDate);
						//return respXzjlValue;
					}
				}
			}else if(type==13) {//13 自然人行政奖励
				tableName="t_1000010010098_ek9kcfC7gn";
				List<XzjlEntity> list = uploadPublicDao.getXzjlByZrr(tableName);
				List<List<XzjlEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzjlEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzjl(spList);
						String xzjlXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政激励转XML内容：{}" + xzjlXmlValue);
						log.debug("行政激励转XML内容：{}", xzjlXmlValue);
						String respXzjlValue = doPostSoap(postUrl, xzjlXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回行政激励上报结果信息：{}", respXzjlValue);
//                    SubmitXzxkRespData xzjlResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzjlValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(XzjlEntity -> XzjlEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzjlResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzjlValue, recordIds, type, reqDate, resDate);
						//return respXzjlValue;
					}
				}
			}else if(type==14) {//14 法人行政裁决
				tableName="t_1000000010078_72Blr6pCCj";
				List<XzcjEntity> list = uploadPublicDao.getXzcjByFr(tableName);
				List<List<XzcjEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzcjEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzcj(spList);
						String xzcjXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政惩戒转XML内容：{}" + xzcjXmlValue);
						log.debug("行政惩戒转XML内容：{}", xzcjXmlValue);
						String respXzcjValue = doPostSoap(postUrl, xzcjXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回行政惩戒上报结果信息：{}", respXzcjValue);
//                    SubmitXzxkRespData xzcjResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzcjValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(XzcjEntity -> XzcjEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzcjResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzcjValue, recordIds, type, reqDate, resDate);
						//return respXzcjValue;
					}
				}
			}else if(type==15) {//15 自然人行政裁决
				tableName="t_1000010010088_bmuDHF0DxX";
				List<XzcjEntity> list = uploadPublicDao.getXzcjByZrr(tableName);
				List<List<XzcjEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzcjEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzcj(spList);
						String xzcjXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政惩戒转XML内容：{}" + xzcjXmlValue);
						log.debug("行政惩戒转XML内容：{}", xzcjXmlValue);
						String respXzcjValue = doPostSoap(postUrl, xzcjXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回行政惩戒上报结果信息：{}", respXzcjValue);
//                    SubmitXzxkRespData xzcjResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzcjValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(XzcjEntity -> XzcjEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzcjResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzcjValue, recordIds, type, reqDate, resDate);
						//return respXzcjValue;
					}
				}
			}else if(type==16) {//16 法人行政确认
				tableName="t_1000000010079_fel4Oc0gfQ";
				List<XzqrEntity> list = uploadPublicDao.getXzqrByFr(tableName);
				List<List<XzqrEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzqrEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzqr(spList);
						String xzqrXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政确认转XML内容：{}" + xzqrXmlValue);
						log.debug("行政确认转XML内容：{}", xzqrXmlValue);
						String respXzqzValue = doPostSoap(postUrl, xzqrXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回行政确认上报结果信息：{}", respXzqzValue);
//                    SubmitXzxkRespData xzqzResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzqzValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(XzqrEntity -> XzqrEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzqzResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzqzValue, recordIds, type, reqDate, resDate);
						//return respXzqzValue;
					}
				}
			}else if(type==17) {//17 自然人行政确认
				tableName="t_1000010010091_HoTa38mRD1";
				List<XzqrEntity> list = uploadPublicDao.getXzqrByZrr(tableName);
				List<List<XzqrEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzqrEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzqr(spList);
						String xzqrXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政确认转XML内容：{}" + xzqrXmlValue);
						log.debug("行政确认转XML内容：{}", xzqrXmlValue);
						String respXzqzValue = doPostSoap(postUrl, xzqrXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回行政确认上报结果信息：{}", respXzqzValue);
//                    SubmitXzxkRespData xzqzResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzqzValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(XzqrEntity -> XzqrEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzqzResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzqzValue, recordIds, type, reqDate, resDate);
						//return respXzqzValue;
					}
				}
			}else if(type==18) {//18 法人其他行政管理
				tableName="t_1000000010083_bisEXzGGeF";
				List<XzqtglEntity> list = uploadPublicDao.getXzqtByFr(tableName);
				List<List<XzqtglEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzqtglEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzqtgl(spList);
						String xzqtglXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政其他转XML内容：{}" + xzqtglXmlValue);
						log.debug("行政其他转XML内容：{}", xzqtglXmlValue);
						String respXzjcValue = doPostSoap(postUrl, xzqtglXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回行政其他上报结果信息：{}", respXzjcValue);
//                    SubmitXzxkRespData xzxkResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzjcValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(XzqtglEntity -> XzqtglEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzxkResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzjcValue, recordIds, type, reqDate, resDate);
						//return respXzjcValue;
					}
				}
			}else if(type==19) {//19 自然人其他行政管理
				tableName="t_1000010010100_4bjNpPRKrv";
				List<XzqtglEntity> list = uploadPublicDao.getXzqtByZrr(tableName);
				List<List<XzqtglEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<XzqtglEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setXzqtgl(spList);
						String xzqtglXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政其他转XML内容：{}" + xzqtglXmlValue);
						log.debug("行政其他转XML内容：{}", xzqtglXmlValue);
						String respXzjcValue = doPostSoap(postUrl, xzqtglXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回行政其他上报结果信息：{}", respXzjcValue);
//                    SubmitXzxkRespData xzxkResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzjcValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(XzqtglEntity -> XzqtglEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzxkResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzjcValue, recordIds, type, reqDate, resDate);
						//return respXzjcValue;
					}
				}
			}else if(type==20) {//20 法人信用承诺
				tableName="t_1000000010398_agbpz1ybsl";
				List<FrPromiseEntity> promiseBookList = uploadXycnDao.getFrPromiseBookLlist();

				List<List<FrPromiseEntity>> parList = ListUtils.partition(promiseBookList, 1);

				for (int i = 0; i < parList.size(); i++) {
					List<FrPromiseEntity> spList = parList.get(i);
					if(spList.get(i).getUUID().equals(String.valueOf(dataId))) {
						SubmitXycnReqData req = new SubmitXycnReqData();
						req.setFrPromise(spList);
						// 上报数据转换成xml
						String frcnsXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("上报法人承诺书转换成xml" + frcnsXmlValue);
						log.debug("法人承诺书XML内容：{}", frcnsXmlValue);
						String respXzxkValue = doPostSoap(postUrl, frcnsXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回法人承诺书上报结果信息：{}", respXzxkValue);
						System.out.println("返回法人承诺书上报结果信息：{}" + respXzxkValue);
//                    SubmitXycnRespData frResp = (SubmitXycnRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXycnRespData.class, respXzxkValue);
						List<String> recordIds = spList.stream().map(FrPromiseEntity -> FrPromiseEntity.getUUID()).collect(Collectors.toList());

//                    保存返回数据
//                    this.saveSubmitLogs(type, frResp.getResp(),recordIds,tableName);
						this.doUpdateLog(tableName, respXzxkValue, recordIds, type, reqDate, resDate);
					}
				}
			}else if(type==21) {//21 自然人信用承诺
				tableName="t_1000010010567_jvhob4c2lb";
				List<ZrrPromiseEntity> promiseBookList = uploadXycnDao.getZrrPromiseBookLlist();

				List<List<ZrrPromiseEntity>> parList = ListUtils.partition(promiseBookList, 1);

				for (int i = 0; i < parList.size(); i++) {
					List<ZrrPromiseEntity> spList = parList.get(i);
					if(spList.get(i).getUUID().equals(String.valueOf(dataId))) {
						SubmitXycnReqData req = new SubmitXycnReqData();
						req.setZrrPromise(spList);
						// 上报数据转换成xml
						String frcnsXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("上报自然人承诺书转换成xml" + frcnsXmlValue);
						log.debug("自然人承诺书XML内容：{}", frcnsXmlValue);
						String respXzxkValue = doPostSoap(postUrl, frcnsXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回自然人承诺书上报结果信息：{}", respXzxkValue);
						System.out.println("返回行自然人承诺书结果信息：{}" + respXzxkValue);
//                    SubmitXycnRespData zrrResp = (SubmitXycnRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXycnRespData.class, respXzxkValue);
						List<String> recordIds = spList.stream().map(ZrrPromiseEntity -> ZrrPromiseEntity.getUUID()).collect(Collectors.toList());

//                    保存返回数据
//                    this.saveSubmitLogs(type, zrrResp.getResp(),recordIds,tableName);
						this.doUpdateLog(tableName, respXzxkValue, recordIds, type, reqDate, resDate);
					}
				}
			}else if(type==22) {//22 法人抽查任务
				tableName="t_1000000010410_dwaw88YojG";
				List<CcrwEntity> list = uploadPublicDao.getCcrw(tableName);
				List<List<CcrwEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<CcrwEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setCcrw(spList);
						String xzqrXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政确认转XML内容：{}" + xzqrXmlValue);
						log.debug("行政确认转XML内容：{}", xzqrXmlValue);
						String respXzqzValue = doPostSoap(postUrl, xzqrXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回行政确认上报结果信息：{}", respXzqzValue);
//                    SubmitXzxkRespData xzqzResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzqzValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(CcrwEntity -> CcrwEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzqzResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzqzValue, recordIds, type, reqDate, resDate);
						//return respXzqzValue;
					}
				}
			}else if(type==23) {//23 自然人抽查任务

			}else if(type==24) {//24 法人抽查结果
				tableName="t_1000000010409_sUlP9D0Apy";
				List<CcjgEntity> list = uploadPublicDao.getCcjg(tableName);
				List<List<CcjgEntity>> parList = ListUtils.partition(list, 1);
				for (int i = 0; i < parList.size(); i++) {
					List<CcjgEntity> spList = parList.get(i);
					if(spList.get(i).getRecordId().equals(String.valueOf(dataId))) {
						PublishSubmitReqData req = new PublishSubmitReqData();
						req.setCcjg(spList);
						String xzqrXmlValue = SubmitConvXmlUtils.convert2Xml(req);
						System.out.println("行政确认转XML内容：{}" + xzqrXmlValue);
						log.debug("行政确认转XML内容：{}", xzqrXmlValue);
						String respXzqzValue = doPostSoap(postUrl, xzqrXmlValue, apiKey, method, methodid, "xxid_001");
						Date resDate = new Date();
						log.info("返回行政确认上报结果信息：{}", respXzqzValue);
//                    SubmitXzxkRespData xzqzResp = (SubmitXzxkRespData) SubmitConvXmlUtils
//                            .convertXml2Object(SubmitXzxkRespData.class, respXzqzValue);
						//保存返回数据
						List<String> recordIds = spList.stream().map(CcjgEntity -> CcjgEntity.getRecordId()).collect(Collectors.toList());
//                    this.saveSubmitLogs(type, xzqzResp.getResp(), recordIds, tableName);
						this.doUpdateLog(tableName, respXzqzValue, recordIds, type, reqDate, resDate);
						//return respXzqzValue;
					}
				}
			}else if(type==25) {//25 自然人抽查结果

			}
		} catch (Exception e) {
			e.printStackTrace();
			log.info("上传数据失败:", e.getMessage());
		}
		return null;
	}


	public String doUpdateLog(String tableName, String json, List<String> tid, int type, Date reqDate, Date resDate) throws IOException {

		// 创建JSON解析器
		JSONParser parser = new JSONParser();

		// 将JSON字符串解析为JSONObject对象
		try {
			org.json.simple.JSONObject jsonObject = (org.json.simple.JSONObject) parser.parse(json);
			List<String> recordIds = new ArrayList<>();
//            recordIds.add(tid);
			// 从JSONObject中获取值
			String status = (String) jsonObject.get("status");//状态
			Long zongnum = (Long) jsonObject.get("zongnum");
			Long chenggongnum = (Long) jsonObject.get("chenggongnum");
			Long shibainum = (Long) jsonObject.get("shibainum");
			//插入推送日志
			DateUtil dataUtil = DateUtil.getInstance();
			String batNo = "BN" + dataUtil.getCurrDate(DateUtil.YYYYMMDDHHMMSS);
			String subDate = dataUtil.getCurrDate(DateUtil.YYYY_MM_DD);


			SubmitLogsInfo logsInfo = new SubmitLogsInfo();
			logsInfo.setReqDate(reqDate);
			logsInfo.setResDate(resDate);
			logsInfo.setBatNo(batNo);
			logsInfo.setType(type);
			logsInfo.setSubDate(subDate);
			logsInfo.setRecStatus(status);
			logsInfo.setZongNum(zongnum.toString());
			logsInfo.setSuccNum(chenggongnum.toString());
			logsInfo.setFailNum(shibainum.toString());
			logsInfo.setTabelName(tableName);
			logsInfo.setTid(String.join(",",tid));
			this.setSubmitLogsInfo(tableName, logsInfo,tid);
			String sbyy = "";
			if(jsonObject.get("subtext") != null && !"".equals(jsonObject.get("subtext"))){
				org.json.simple.JSONArray subtext11= (org.json.simple.JSONArray) jsonObject.get("subtext");
				String subtext = (String)  subtext11.get(0).toString();//返回值
//                if(subtext.indexOf("cuowustr")>0){
//                    List<Map> subtexts = JSONArray.parseArray(subtext,Map.class);
//                    for (Map sub: subtexts){
//                        if(sub.get("cuowustr") !=null && !"".equals(sub.get("cuowustr"))){
//                            String  info = Normalizer.normalize(sub.get("cuowustr").toString(), Normalizer.Form.NFKC);
//                            sub.put("cuowustr",info);
//                        }
//                    }
//                    subtext = JSONArray.toJSONString(subtexts);
//                    sbyy = subtexts.get(0).get("cuowustr").toString();
//                }
				org.json.simple.JSONObject test = (org.json.simple.JSONObject) parser.parse(subtext);
				sbyy = (String) test.get("cuowustr");//状态
				logsInfo.setCuowustr(subtext);
			}

			if(chenggongnum == 1){//更新数据表推送状态
				//
				uploadPublicDao.updateXzStatusByRecordIds(tableName,"Y","推送成功","",tid);//需改原数据的状态
//                logsInfo.setSuccNum("1" );
//                logsInfo.setFailNum("0");
//                logsInfo.setRecStatus("1");
			}else{
				uploadPublicDao.updateXzStatusByRecordIds(tableName,"N","推送失败",sbyy,tid);//需改原数据的状态
//                JSONObject jsonObject1 = (JSONObject) parser.parse(subtext);
//                logsInfo.setTabelName(tableName);
//                String cuowustr = jsonObject1.get("cuowustr").toString();
//                logsInfo.setSuccNum("0" );
//                logsInfo.setFailNum("1");
//                logsInfo.setRecStatus("1");
//                String  info = Normalizer.normalize(cuowustr, Normalizer.Form.NFKC);
//                logsInfo.setRemarkInfo(info);
			}
			uploadPublicDao.saveSubmitLogsInfo(logsInfo);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}


	public String doPostSoap(String postUrl, String soapXml, String apiKey,
							 String soapAction,String tid,String xxid) throws IOException {
		String StringResult = "";
		//不需要手动关闭httpClient
		OkHttpClient client = new OkHttpClient();
		FormBody.Builder builder = new FormBody.Builder();
		builder.add("APIKEY",apiKey);//接口秘钥
		builder.add("tid",tid);//报送类别ID
		builder.add("MethodName",soapAction);//报送类别方法名称
		builder.add("exlfilelist_id","");//批量报送批次ID，单条报送时为空
		builder.add("xxid", xxid);   //单条报送信息 ID，批次报送时为空
		builder.add("UserCode", "1620"); //在市平台的用户ID
		builder.add("permissionXml", soapXml); //信息主体XML字符串
		Request request = new Request.Builder()
				.url(postUrl).post(builder.build())
				.build();
		try {
			Response response = client.newCall(request).execute();
			StringResult = response.body().string();
		} catch (IOException e) {
			StringResult = "errorException:" + e.getMessage();
			e.printStackTrace();

		}
		return StringResult;

	}

	public void setSubmitLogsInfo(String tableName,SubmitLogsInfo logsInfo,List<String> tid){
		try{
			List<Map<String,Object>> configs = uploadPublicDao.selectSubmitLogsConfigs(tableName);
			List<Map<String,Object>> dataList = uploadPublicDao.selectData(tableName,tid);
			Map<String,Object> config = new HashMap<>();
			for(Map<String,Object> c:configs){
				config.put(c.get("log_filed").toString(),c.get("col_name"));
			}
			String titleName =  dataList.stream().map(d -> getStringToObject(d.get(config.get("titleName")))).collect(Collectors.joining(","));
			String titleId = dataList.stream().map(d -> getStringToObject(d.get(config.get("titleId")))).collect(Collectors.joining(","));
			String bzxrName = dataList.stream().map(d -> getStringToObject(d.get(config.get("bzxrName")))).collect(Collectors.joining(","));
			String bzxrId = dataList.stream().map(d -> getStringToObject(d.get(config.get("bzxrId")))).collect(Collectors.joining(","));
			String zxdwbh = dataList.stream().map(d -> getStringToObject(d.get(config.get("zxdwbh")))).collect(Collectors.joining(","));
			String zxdwName = dataList.stream().map(d -> getStringToObject(d.get(config.get("zxdwName")))).collect(Collectors.joining(","));
			logsInfo.setTitleName(titleName);
			logsInfo.setTitleId(titleId);
			logsInfo.setBzxrName(bzxrName);
			logsInfo.setBzxrId(bzxrId);
			logsInfo.setZxdwbh(zxdwbh);
			logsInfo.setZxdwName(zxdwName);
		}catch (Exception e){
			e.printStackTrace();
		}
	}

	public String getStringToObject(Object object){
		if(!org.springframework.util.StringUtils.isEmpty(object)){
			return object.toString();
		}
		return "";
	}
	
}
